/**
 * Live GPS Tracking Application
 * Status screen (satellite information)
 *
 * Copyright 2009, Ivar Clemens
 */

package nl.ivarclemens.gpstrack.ui;

import nl.ivarclemens.gpstrack.nmea.PositionEvent;
import nl.ivarclemens.gpstrack.GPSTrack;
import javax.microedition.lcdui.*;

public class StatusUI extends Form implements CommandListener {

    private GPSTrack gpstrack = null;
    private SatelliteWidget satellite = null;
    private Command backCommand;

    public StatusUI(GPSTrack gpstrack)
    {
        super("Status");

        this.gpstrack = gpstrack;

        int satWidth = Math.min(this.getWidth(), this.getHeight());

        satellite = new SatelliteWidget();
        satellite.setPreferredSize(satWidth, satWidth);

        this.gpstrack.getNMEAParser().addSatelliteListener(satellite);

        this.append(satellite);

        backCommand = new Command("Back", Command.BACK, 2);
        this.addCommand(backCommand);
        this.setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d)
    {
        if(c == backCommand)
            gpstrack.gotoScreen("menu");
    }
}
